package JDBC_learn;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
// Statement
public class JDBCDemo3 {
   @Test
    public void testDML() throws Exception {
       //1.注册驱动
       //  Class.forName("com.mysql.jdbc.Driver");
       //2.获取链接
       // String url="jdbc:mysql://127.0.0.1:3306/itheima";
       //如果连接的是本机的myaql并且端口号是默认的3306可以简化书写
       String url="jdbc:mysql:///itheima?useSSL=false";
       String username="root";
       String password="11235813";
       Connection conn = DriverManager.getConnection(url, username, password);
       //3.定义sql
       String sql="drop database db2";
       //4.获取执行sql的对象Statement
       Statement stmt = conn.createStatement();
       //5.执行sql
       int count=stmt.executeUpdate(sql);//受影响的行数
       //6.处理结果
       //System.out.println(count);
        if (count>0){
            System.out.println("修改成功~");
        }else {
            System.out.println("修改失败");
        }
       //7.释放资源
       stmt.close();
       conn.close();

   }
}
